<?php

error_reporting(0);

$module = $_GET['m'];

if($module == 'load_data'){
	
	require_once("simple_html_dom.php");
	
	$link = (isset($_GET['l'])) ? $_GET['l'] : 'http://www.sunfrogshirts.com/search/index.cfm?SEARCH=personal+name';
	$affID = "24244";
	$html = file_get_html($link);
	
	if($html){
		$stt = 1;
		$data = '';
		$products = $html->find("#col2 .productIcon");
		$end = count($products);
		foreach($products as $product){
			
			$title=$product->find("table td.product-Title",0);
			$tagA = $product->find("div.frame center a",0);
			$tagA->href = $tagA->href . "?$affID";
			$tagA->target = "_blank";
			$cat = $product->find("table td.product-cat",0);
			$price = $product->find("table td.product-price",0);
			
			$data .= "<div class='col-xs-6 col-sm-4 col-md-3 col-lg-2'>";
				$data .= "<div class='thumbnail'>";
					$data .= $tagA->parent();
					$data .= "<div class='caption'>";
						$data .= "<h3 class='text-overflow'>".$title->plaintext."</h3>";
						$data .= "<p class='clearfix' style='margin-bottom:0'>";
							$data .= "<label class='text-overflow label label-success padding10 pull-left'>".$cat->innertext."</label>";
							$data .= "<label class='label label-primary padding10 pull-right'>".$price->plaintext."</label>";
						$data .= "</p>";
					$data .= "</div>";
				$data .= "</div>";
			$data .= "</div>";
			
			if($stt == 6 || $stt == $end) echo $data;
			$stt++;
		}
	}
}